package net.oschina.app.testcases;

import android.content.Context;

import android.util.Log;
import android.view.View;

import android.widget.ListView;
import android.widget.TextView;

import net.oschina.app.BasicTestCase;


/**
 * Created by Aaron on 2017/3/5.
 */

public class FirstTestCase extends BasicTestCase {

    public void testName() throws Exception {
//        View myTab = solo.getView("net.oschina.app:id/nav_item_me");
//        solo.clickOnView(myTab);
//        solo.waitForText("我的团队",1,1000);
//        solo.clickOnView(solo.getView("net.oschina.app:id/iv_portrait"));
//        solo.waitForText("注册",1,1000);
//        EditText name = (EditText) solo.getView("net.oschina.app:id/et_username");
//        solo.enterText(name,"helloworld");
//        EditText pwd = (EditText) solo.getView("net.oschina.app:id/et_password");
//        solo.enterText(pwd,"123456");
//        solo.clickOnView(solo.getView("net.oschina.app:id/btn_login"));
//        Assert.assertTrue(solo.searchText("用户名或口令错",true));
//        //如果界面上有相同id的控件定位方式
//        ListView list = (ListView) solo.getView("net.oschina.app:id/listView");
//        View line = list.getChildAt(2);
//        TextView newsTitle = (TextView) line.findViewById(idParse("net.oschina.app:id/tv_title"));
//        TextView newsTitle2 = (TextView) line.findViewById(R.id.tv_title);
//        Log.i("AUTO", "======================" + newsTitle.getText().toString());
//        assertEquals(newsTitle.getText().toString(), newsTitle2.getText().toString());

    }


    private int idParse(String id) {
        Context targetContext = getInstrumentation().getTargetContext();
        String packageName = targetContext.getPackageName();
        int viewId = targetContext.getResources().getIdentifier(id, "id", packageName);
        return viewId;
    }
}
